package com.hex.liyue.giftmodule.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.hex.liyue.R;
import com.hex.liyue.commonmodule.activity.BaseActivity;
import com.hex.liyue.commonmodule.glide.GlideCircleTransform;
import com.hex.liyue.commonmodule.utils.DateUtils;
import com.hex.liyue.commonmodule.utils.SexUtils;
import com.hex.liyue.commonmodule.utils.StatusBarCompatUtils;
import com.hex.liyue.giftmodule.adapter.AdapterGiveDetails;
import com.hex.liyue.giftmodule.bean.GiveGiftsBean;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by WJ on 2016/6/20.
 * 这是一个赠送详情的界面
 */
public class GiveGiftDetailsActivity extends BaseActivity {
    @Bind(R.id.iv_toobar_back)
    ImageView ivToobarBack;
    @Bind(R.id.tv_toobar_title)
    TextView tvToobarTitle;

    @Bind(R.id.tv_give_states)
    TextView mTvStates;
    @Bind(R.id.tv_give_nickname)
    TextView mTvNums;
    @Bind(R.id.tv_give_prices)
    TextView mTvPrices;
    @Bind(R.id.tv_create_date)
    TextView mTvDate;

    @Bind(R.id.tv_ugive_signature)
    TextView tvSingature;
    @Bind(R.id.tv_ugive_sex)
    TextView tvSex;
    @Bind(R.id.tv_ugive_nickname)
    TextView tvNickName;

    @Bind(R.id.iv_give_gift_icon)
    ImageView ivGiveGiftIcon;
    @Bind(R.id.iv_give_gift_avater)
    ImageView ivGiveGiftAvater;
    @Bind(R.id.rv_shopping_list)
    RecyclerView rvShoppingList;

    @Override
    protected void bindPresenter() {

    }

    @Override
    protected void initData(Bundle extras) {
        GiveGiftsBean.DataBean dataBean = (GiveGiftsBean.DataBean) getIntent().getSerializableExtra("dataBean");
        mTvDate.setText("赠送时间：" + DateUtils.getFormatDate(dataBean.send_time * 1000, "yyyy-MM-dd"));
        mTvNums.setText("赠送人：" + dataBean.to_user.nickname);
        mTvPrices.setText("商品金额：￥" + dataBean.total_cash);
        if (dataBean.status == 1) {
            mTvStates.setText("赠送状态：赠送中");
        } else if (dataBean.status == 2) {
            mTvStates.setText("赠送状态：待接收");
        } else if (dataBean.status == 3) {
            mTvStates.setText("赠送状态：已被接受");
        } else if (dataBean.status == 4) {
            mTvStates.setText("赠送状态：被拒收");
        } else {
            mTvStates.setText("赠送状态：已接受");
        }
        Glide.with(this)
                .load(dataBean.to_user.avatar)
                .error(R.drawable.no_icon)
                .transform(new GlideCircleTransform(this))
                .into(ivGiveGiftAvater);
        tvNickName.setText("昵称：" + dataBean.to_user.nickname);
        tvSex.setText("性别：" + SexUtils.getSex(dataBean.to_user.sex));
        tvSingature.setText("个性签名：" + dataBean.to_user.signature);

        rvShoppingList.setLayoutManager(new LinearLayoutManager(this));
        AdapterGiveDetails adapterShoppingDetails = new AdapterGiveDetails(dataBean.gift_list);
        adapterShoppingDetails.setOnItemClickListener(new AdapterGiveDetails.OnItemClickListener() {
            @Override
            public void onItemClickListener(int position) {

            }
        });
        rvShoppingList.setAdapter(adapterShoppingDetails);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_give_gift_details;
    }

    @Override
    protected void initToolbar() {
        StatusBarCompatUtils.compat(this);
        ivToobarBack.setVisibility(View.VISIBLE);
        tvToobarTitle.setText("赠送详情");
    }

    @OnClick({R.id.iv_toobar_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_toobar_back:
                onBackPressed();
                break;
        }
    }
}
